package Servlet.info;

import Server.info.novelInfoServer;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "novelInfoServlet", value = "/novelInfoServlet")
public class novelInfoServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ServletContext context = this.getServletContext();
        // 通过ServletContext对象获取文件的真实路径
        String realPath = context.getRealPath("");
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        String url="novelInfo.jsp";

        try {
            novelInfoServer server=new novelInfoServer(request,response);
            server.queryNovelBean();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }finally {
            request.getRequestDispatcher(url).forward(request, response);		//转发
        }

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }
}
